home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
newsgroups
/
misc.20010921-20020314
/
000287_fdc@columbia.edu_Tue Jan 8 14:32:57 EST 2002.msg
< prev
next >
Wrap
Text File
|
2020-01-01
|
4KB
|
123 lines
Article: 13119 of comp.protocols.kermit.misc
Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
From: fdc@columbia.edu (Frank da Cruz)
Newsgroups: comp.protocols.kermit.misc
Subject: Re: Kermit 8 FTP scripting
Date: 8 Jan 2002 14:32:47 -0500
Organization: Columbia University
Lines: 106
Message-ID: <a1fhgv$sgj$1@watsol.cc.columbia.edu>
References: <336f652d.0201081116.4cd7a675@posting.google.com>
NNTP-Posting-Host: watsol.cc.columbia.edu
X-Trace: newsmaster.cc.columbia.edu 1010518368 6517 128.59.39.139 (8 Jan 2002 19:32:48 GMT)
X-Complaints-To: postmaster@columbia.edu
NNTP-Posting-Date: 8 Jan 2002 19:32:48 GMT
Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:13119
In article <336f652d.0201081116.4cd7a675@posting.google.com>,
Shifeux <shifeux@hotmail.com> wrote:
: Hello, I am writing a small kermit script using the built in ftp
: client. The script works fine as far as stepping through the transfer,
: but I am having problems working with the log files. I would like to
: keep a detailed transaction log containing the status of the issued
: commands. For example, when the script issues the following command:
:
: ftp cd \%r
:
: i would like to be able to send a line of text to the transaction log
: to indicate the status of that command. I am able to do that using
: the if fail or if success in the next line of the sctipt. But for a
: failure I need to exit the script rather than carry through with other
: commands. My example is as follows:
:
: ftp cd \tmp\hello\
: if success write TRANSACTION-LOG FTP Server Message:
: \v(ftp_message)\13\10
: if fail write TRANSACTION-LOG FTP Server Message:
: \v(ftp_message)\13\10
:
First of all, I assume these IF FAIL commands don't have line breaks in your
actual script. If they do, of course, the script has illegal syntax. So
what you meant to write was:
ftp cd \tmp\hello\
if success write TRANSACTION-LOG FTP Server Message: \v(ftp_message)\13\10
if fail write TRANSACTION-LOG FTP Server Message: \v(ftp_message)\13\10
Second: You can eliminate the ugly \13\10 notation as follows:
ftp cd \tmp\hello\
if success writeln TRANSACTION-LOG FTP Server Message: \v(ftp_message)
if fail writeln TRANSACTION-LOG FTP Server Message: \v(ftp_message)
Third: You shouldn't put an IF FAIL command after an IF SUCCESS command
unless you really mean to; I don't think that's what you want in this. So:
ftp cd \tmp\hello\
if success {
writeln TRANSACTION-LOG FTP Server Message: \v(ftp_message)
} else {
writeln TRANSACTION-LOG FTP Server Message: \v(ftp_message)
}
Fourth: Since the IF and ELSE commands are identical, you don't need
the IF statement at all:
ftp cd \tmp\hello\
writeln TRANSACTION-LOG FTP Server Message: \v(ftp_message)
Fifth: Backslash is a special character in Kermit commands. You might need
to double them in your FTP CD command:
ftp cd \\tmp\\hello\\
Or try:
ftp cd /tmp/hello/
which might be accepted by the server.
: I can't seem to add in an exit command to the if fail line. If i have:
:
: if fail exit 1 write TRANSACTION-LOG FTP Server message:
: \v(ftp_message)
:
: the transaction log is never written.
:
Did you give a LOG TRANSACTIONS command to open it?
The optional EXIT command arguments are (1) a number (exit status code) and
(2) a message to print (not a command to execute).
: How and i string along more than
: 1 command in this statement? A (,) does not do the trick.
:
The way to group commands in an IF statement is:
if <condition> {
command
command
...
}
Of course you can also have an ELSE part with one or more commands:
if <condition> {
command
command
...
} else {
command
command
...
}
In your case:
if fail {
writeln TRANSACTION-LOG FTP Server message: \v(ftp_message)
exit 1
}
- Frank